import {defineStore} from "pinia";
import type { AgvConfig } from "@/axios/types";
import { ref } from 'vue'

export const useSetting = defineStore('setting',{
    state: (): { config: AgvConfig; useDb: boolean } => ({
        config: {
            host: "192.168.2.2",
            drivePort: 8001,
            analysisPort: 8002,
            cloudUrl: "https://api.inspection.com",
            cam1: "rtsp://192.168.1.201:554/stream1",
            username1: "admin",
            password1: "password123",
            cam2: "rtsp://192.168.1.202:554/stream1",
            username2: "admin",
            password2: "password123",
            cam3: "rtsp://192.168.1.203:554/stream1",
            username3: "admin",
            password3: "password123",
            cam4: "rtsp://192.168.1.204:554/stream1",
            username4: "admin",
            password4: "password123",
        },
        useDb: false
    }),
    actions:{
        updateConfig(newConfig: Partial<AgvConfig>) {
            this.config = { ...this.config, ...newConfig };
        },
        setUseDb(flag: boolean) {
            this.useDb = flag;
        }
    },
    persist: true
})

const agvConfig = ref<AgvConfig>({
    host: "192.168.2.2",
    drivePort: 8001,
    analysisPort: 8002,
    cloudUrl: "https://api.inspection.com",
    cam1: "rtsp://192.168.1.201:554/stream1",
    username1: "admin",
    password1: "password123",
    cam2: "rtsp://192.168.1.202:554/stream1",
    username2: "admin",
    password2: "password123",
    cam3: "rtsp://192.168.1.203:554/stream1",
    username3: "admin",
    password3: "password123",
    cam4: "rtsp://192.168.1.204:554/stream1",
    username4: "admin",
    password4: "password123",
})

const webConfig = ref({})

// OpenAI API Configuration
const openaiBaseURL = ref('https://api.openai.com/v1')
const openaiApiKey = ref('')
const openaiModel = ref('gpt-4-turbo')
